Skip to content

Create aip for Aptos Intent Framework#511

Open
runtian-zhou wants to merge 5 commits intoaptos-foundation:mainfrom
runtian-zhou:patch-5
Open

Create aip for Aptos Intent Framework#511
runtian-zhou wants to merge 5 commits intoaptos-foundation:mainfrom
runtian-zhou:patch-5

Conversation

@runtian-zhou
Copy link
Contributor

No description provided.

aips/aip-x.md Outdated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does dispensable_resource sounds better here?

aips/aip-x.md Outdated
Copy link

@ch4r10t33r ch4r10t33r Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you intending for the argument to be a proof (either zk-proof or storage proof) that can be verified on-chain?

In theory, we could represent the argument as a function f(state, intent) -> bool, where solvers submit proofs for on-chain verification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current design, there's no proof involved: user specifies the post condition the transaction will need to meet, and aptos framework will assert this transaction can only be committed if post condition has been met. Argument is just some auxillary data to help the framework determine whether the transaction can be committed. It would be easier if you look at the move code directly.


With those types being generic, we can implement different trading intents easily:
- If `Target` is instantiated with `FungibleAsset`, it means we are trading a Move value for a specific fungible asset.
- If `Target` is instantiated with `LinearTransferRef`, it means we are trading a Move value for an Object.
Copy link

@ch4r10t33r ch4r10t33r Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also include NonFungibleAsset as a type? Some DeFi protocols mint NFTs for specific staking or deposit operations, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are just examples. You can put arbitrary type here.

Copy link
Contributor

@igor-aptos igor-aptos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a note about this not being published at 0x1.

you can look at https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-72.md#risks-and-drawbacks for what they wrote there, but it could probably be explained a bit more (and the reasons for going that way)

aips/aip-x.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not necessarily for trading, but for creating offers. (i.e. offer can be more general than a trade)

For example, you could have an offer for a bet.

aips/aip-x.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the framework => in this AIP

aips/aip-x.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sentence not finished?

aips/aip-x.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Framework code for creating and validating intents.
=>
Library code for creating and validating intents.

- If `Target` is instantiated with `LinearTransferRef`, it means we are trading a Move value for an Object.
- If `Source` is instantiated with `TransferRef`, it means we are giving out ownership to an Object given certain condition.
- If `Source` is instantiated with `FungibleAsset`, it means we are giving out a certain fungible asset given certain condition.
- This doesn't quite work because `FungibleAsset` is not storable. The real implementation would look like giving out ownership of a `FungibleStore`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be hidden in the intent? i.e. it stores FungibleStore, but returns extracted FungibleAsset to the caller?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is currently hidden for implementation.

aips/aip-x.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sentence probably goes to future work

}
```
Here we are defining an example of intent where the unlock condition is receiving a certain amount of a given fungible asset type. `Argument` type is instantiated to `FungibleAssetLimitOrder` and `Witness` type is instantated to `FungibleAssetRecipientWitness` in this example. In the arugment, we specify the amount and the type of FA we would like to receive. The check will then be implemented by first checking if the passed in `FungibleAsset` meets the requirement set in the `FungibleAssetLimitOrder` and deposit the FA to the issuer's primary fungible storage if the conditions are met. Once the checks are completed, we will provide the witness `FungibleAssetRecipientWitness` to complete this intent session.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs an example of snippet of code of what the issuer and settler would need to do , for the above fungible_asset_intent_hooks.

aips/aip-x.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not aptos_framework , but a different adress

aips/aip-x.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rephrase this:

As the system is first-come first-serve, the intent claiming transaction can be front-runned by whoever sees it - mempool operator, validator operator, etc. Since anyone is able to sign transaction to claim intent solution, anyone can take the intent solving transaction submitted by the solver and sign the same transaction with its own address to be able to claim the lucrative ones. If main value comes from finding the route, and not being willing to settle, privacy of submitted transactions will become imporatnt. Intent Solver might want to run a validator node or partner with validator operator. Additionally in the future, support for "secret transactions" , that are revealed only at the time of execution might be added.

aips/aip-x.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"secret transactions"

@runtian-zhou
Copy link
Contributor Author

Update the PR with @igor-aptos's comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments